include ../common.mk

##### ---------------------------------------------#####
##### Define All Target and source files #####
##### ---------------------------------------------#####
TARGET = libmoose_core.a
TARGETSrc = $(wildcard *.c)

AllTestSrc = $(subst .c,.$(TEST),$(TARGETSrc))
AllTest = $(subst .$(TEST),,$(AllTestSrc))
##### ---------------------------------------------#####
##### End Define All Target and source files #####
##### ---------------------------------------------#####


##### ---------------------------------------------#####
##### Define All Target generate rules #####
##### ---------------------------------------------#####
$(TARGET): $(TARGETSrc) 
	$(CC) $(S_LANGUAGE) $^ $(CFLAGS) $(STATIC_FLAGS) 
	@$(AR) $@ *.o
	@$(RM) *.o
	@$(MKDIR) $(LibDir)
	@$(CP) $@ $(LibDir)

$(AllTest):
	$(CC) $(S_LANGUAGE) $@.$(TEST) $(TEST_FLAGS) -o $@
	@$(MKDIR) $(TestBinDir)
	@$(CP) $@ $(TestBinDir)
##### ---------------------------------------------#####
##### End Define All Target generate rules #####
##### ---------------------------------------------#####


test:$(AllTest)

all:$(TARGET) $(AllTest) 

clean:
	@$(RM) $(TARGET) $(AllTest) $(BinDir) $(TestBinDir) $(LibDir)
